home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Think Class Libraries / Intelligent classes 1.0 / CIntelligentDecorator.c next >
Encoding:
C/C++ Source or Header  |  1994-11-30  |  1.7 KB  |  88 lines  |  [TEXT/KAHL]

  1. /****
  2.  *    CIntelligentDecorator.c
  3.  *
  4.  *    This class makes the Decorator a little more intelligent.
  5.  *
  6.  *    Copyright © 1993 Quipus, by Mårten Sörliden.  All rights reserved.
  7.  *
  8.  ****/
  9.  
  10. #include <Constants.h>
  11. #include <CDesktop.h>
  12. #include <CList.h>
  13. #include <CIntelligentDecorator.h>
  14. #include <CIntelligentWindow.h>
  15.  
  16.  
  17. /*** Global Variables ***/
  18.  
  19. extern CDesktop *gDesktop;
  20.  
  21.  
  22. /** Construction and destruction methods **/
  23.  
  24. void CIntelligentDecorator::IIntelligentDecorator()
  25. {
  26.     IDecorator();
  27.     SetFirstLocation();
  28. }
  29.  
  30. void CIntelligentDecorator::Dispose(void)
  31. {
  32.  
  33.     inherited::Dispose();
  34. }
  35.  
  36.  
  37. /** Accessing methods **/
  38.  
  39. short CIntelligentDecorator::GetWNum()
  40. {
  41.     CList *theWindows;
  42.     long n, i;
  43.     CObject *theObject;
  44.     CIntelligentWindow *theWindow;
  45.     Str255 theTitle;
  46.     short theCount, tempCount;
  47.     
  48.     theCount = 1;
  49.     theWindows = gDesktop->itsWindows;
  50.     n = theWindows->GetNumItems();
  51.     for (i = 1; i <= n; i++) {
  52.         theObject = theWindows->NthItem(i);
  53.         if (member(theObject, CIntelligentWindow)) {
  54.             theWindow = (CIntelligentWindow *)theObject;
  55.             tempCount = theWindow->GetWNum();
  56.             if (tempCount >= theCount)
  57.                 theCount = tempCount + 1;
  58.         }
  59.     }
  60.     return(theCount);
  61. }
  62.  
  63.  
  64. /** Window methods **/
  65.  
  66. void CIntelligentDecorator::SetFirstLocation()
  67. {
  68.     hLocation = LEFT_SMARGIN - 1;
  69.     vLocation = TOP_SMARGIN + GetMBarHeight() - 1;
  70. }
  71.  
  72. // Override
  73. void    CIntelligentDecorator::PlaceNewWindow(CWindow *theWindow)
  74. {                
  75.     if (member(theWindow, CIntelligentWindow))
  76.         theWindow->Zoom(inZoomOut);
  77.     StaggerWindow(theWindow);
  78.     if (!member(theWindow, CIntelligentWindow))
  79.         theWindow->ChangeSize(wWidth, wHeight);    
  80. }
  81.  
  82. // Override
  83. void    CIntelligentDecorator::StaggerWindow(CWindow *theWindow)
  84. {
  85.     inherited::StaggerWindow(theWindow);
  86.     if (index == 1)
  87.         SetFirstLocation();
  88. }